package cn.edu.imnu.service.impl;

import cn.edu.imnu.entry.dto.SaleDeleteDto;
import cn.edu.imnu.entry.dto.SaleUpdateDto;
import cn.edu.imnu.entry.vo.SaleRegionListVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.edu.imnu.entry.po.Sale;
import cn.edu.imnu.service.SaleService;
import cn.edu.imnu.mapper.SaleMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author HY3423
* @description 针对表【sale】的数据库操作Service实现
* @createDate 2025-05-28 09:58:19
*/
@Service
public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale>
    implements SaleService{
    @Resource
    private SaleMapper saleMapper;

    @Override
    public List<SaleRegionListVo> getRegionList() {

        List<SaleRegionListVo> saleRegionList;
        saleRegionList = saleMapper.getRegionList();

        return saleRegionList;
    }

    @Override
    public boolean deleteThisData(SaleDeleteDto saleDeleteDto) {

        return this.removeById(saleDeleteDto.getSaleId());
    }

    @Override
    public boolean updateData(SaleUpdateDto updateDto) {
        if (updateDto == null || updateDto.getSaleId() == null) {
            throw new IllegalArgumentException("参数不合法");
        }

        Sale sale = new Sale();
        sale.setSaleId(updateDto.getSaleId());
        sale.setSaleName(updateDto.getSaleName());
        sale.setSalePhone(updateDto.getSalePhone());
        return this.updateById(sale);
    }
}




